import axios from "axios";
axios.defaults.baseURL = process.env.VUE_APP_PROXY_TARGET  //根据环境变量设置不同的baseURL

let requests = axios.create({
    //baseURL: process.env.VUE_APP_PROXY_TARGET,
    timeout: 5000,
    /*headers: {
        'X-Requested-with': 'XMLHttpRequest',
    }*/
});

requests.interceptors.request.use((config) => {
    return config;
})

requests.interceptors.response.use((res) => {
    // console.log(res)
    return res.data;
}, (error) => {
    console.log(error);
    return Promise.reject(new Error("faile"));
})

export default requests;
